package im.eventpackage;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/* -->ESEMPIO D'UTILIZZO<--
 * 
        List types=new ArrayList();
        List topics=new ArrayList();
        List objects=new ArrayList();

        String topic1="pizza";
        String topic2="kebab";
        String topic3="pub";
        String topic4="music";

        topics.add(topic1);
        topics.add(topic2);
        topics.add(topic3);
        topics.add(topic4);

        String type1="Market";
        String type2="EnglishMarket";
        String type3="Disaster";
        String type4="Integer";

        types.add(type1);
        types.add(type2);
        types.add(type3);
        types.add(type4);

        int value1=1;
        int value2=3;
        int value3=4;

        objects.add(value1);
        objects.add(value2);
        objects.add(value3);
        EventGenerator evg=new EventGenerator();
        for(int i=0;i<10;i++){

            String id=""+i;
            Event ev = evg.generateEvent(id, types, topics, objects);

            System.out.println("evento:"+id);
            System.out.println("id: "+ev.getId());
            System.out.println("name: "+ev.getName());
            System.out.println("topic: "+ev.getTopic());
            System.out.println("type: "+ev.getType());
            System.out.println("value: "+ev.getValue());
            System.out.println("content: "+ev.getContent());
            System.out.println();

        }
 */


import im.numgenerator.PseudoRandomGenerator;
import java.util.List;

/**
 *
 * @author Giovanni
 */
public class EventGenerator {

    PseudoRandomGenerator prg;

    public EventGenerator(PseudoRandomGenerator prg ) {
        this.prg = prg;
    }

    public Event generateEvent(String id, List types, List topics, List objects){

        Event ev=new Event(null, null, null, null,null, null);

        int sizeTypes=types.size();
        int sizeTopics=topics.size();
        int sizeObjects=objects.size();

        int rTypes=(int) (prg.getUniform() * sizeTypes);
        int rTopics= (int) (prg.getUniform() * sizeTopics);
        int rObjects =(int) (prg.getUniform() * sizeObjects);

        ev.setId(id);

        ev.setType(types.get(rTypes));
        ev.setTopic((String) topics.get(rTopics));
        ev.setValue(objects.get(rObjects));
        ev.setName("id"+(String) topics.get(rTopics)+prg.getUniform()*100);
        ev.setContent("name == "+(String) topics.get(rTopics)+" or " +"value =="+objects.get(rObjects).toString());

        return ev;


    }


}
